<template>  
  <div id="app">  
    <nav>  
      <router-link to="/products">商品列表</router-link>  
      <router-link to="/cart">购物车</router-link>  
      <span>购物车数量: {{ cartLength }}</span>  
    </nav>  
    <router-view/>  
  </div>  
</template>  
  
<script>  
import { mapGetters } from 'vuex'  
  
export default {  
  computed: {  
    ...mapGetters(['cartLength']) // 映射Vuex store中的getters  
  }  
}  
</script>